import axios from "axios";
import { defineStore } from "pinia";
import { News } from "../../types/data";

export default defineStore('news',{
  state:() => ({
    list:[] as News[]
  }),
  actions:{
    async getNewsList(id:number){
      const res = await axios.get(
        `http://geek.itheima.net/v1_0/articles?channel_id=${id}&timestamp=${Date.now()}`
      )
      console.log(res);
      this.list = res.data.data.results
    }
  }
})